package com.wei.duowan.bbs.ui.fragment;

import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.wei.duowan.bbs.R;
import com.wei.duowan.bbs.presenter.BasePresenter;
import com.wei.duowan.bbs.ui.adapter.BaseRecyclerViewAdapter;
import com.wei.duowan.bbs.ui.adapter.BaseViewHolder;

import java.util.Arrays;

import butterknife.Bind;

/**
 * 作者：赵若位
 * 时间：2019/8/1 15:11
 * 联系方式：1070138445
 * 功能：首页
 */
public class MsgFragment extends BaseFragment
{
    @Bind(R.id.recyclerView)
    RecyclerView mRecyclerView;

    private BaseRecyclerViewAdapter mAdapter;

    @Override
    protected BasePresenter createPresenter()
    {
        return null;
    }

    @Override
    protected int getLayoutID()
    {
        return R.layout.fragment_msg;
    }

    @Override
    protected void initView()
    {
        setTitle(R.string.msg);
        LinearLayoutManager manager = new LinearLayoutManager(mActivity);
        mRecyclerView.setLayoutManager(manager);
        mAdapter = new BaseRecyclerViewAdapter<String>(mActivity, R.layout.item_message)
        {
            @Override
            protected void convert(int position, @Nullable BaseViewHolder holder, @Nullable final String s)
            {
                holder.setCircleResource(R.id.item_image,
                        position == 0 ? R.mipmap.head_notification : R.mipmap.head_comment)
                        .setText(R.id.item_title, s)
                        .itemView.setOnClickListener(new View.OnClickListener()
                {
                    @Override
                    public void onClick(View view)
                    {
                       MsgFragment.this.mActivity .alert(s);
                    }
                });
            }
        };
        mAdapter.bindRecyclerView(mRecyclerView);
        mAdapter.setNewData(Arrays.asList(new String[]{"系统消息", "评论消息"}));
    }

}
